﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VicMessenger.DB;

namespace VicMessenger.DAL
{
    public class CustomFieldDAL
    {
        public static List<proc_CustomeField_SelectResult> GetCustomField(long? prmCustomFieldID, long? prmContactID)
        {
            try
            {
                using (CustomFieldDBDataContext db = new CustomFieldDBDataContext())
                {
                    return db.proc_CustomeField_Select(prmCustomFieldID, prmContactID).ToList();
                }
            }
            catch (Exception)
            {
                return null;
            }
        }

        //public static List<proc_CustomeFieldTemplate_SelectResult> GetCustomFieldTemplate(int? prmCampaignID)
        //{
        //    try
        //    {
        //        using (CustomFieldDBDataContext db = new CustomFieldDBDataContext())
        //        {
        //            return db.proc_CustomeFieldTemplate_Select(prmCampaignID).ToList();
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        return null;
        //    }
        //}

        public static long? InsertUpdateCustomField(proc_CustomeField_SelectResult prmContact)
        {
            try
            {
                long? retCustomFieldID = 0;
                using (CustomFieldDBDataContext db = new CustomFieldDBDataContext())
                {
                    db.proc_CustomeField_InsertUpdate(prmContact.CustomFieldID,
                                                      prmContact.ContactID,
                                                      prmContact.FieldName,
                                                      prmContact.FieldValue, ref retCustomFieldID);



                    return retCustomFieldID;
                }
            }
            catch (Exception)
            {
                return 0;
            }
        }
    }
}
